
import os
import re

def miftrans(rfp):
    fo = open(rfp, "r+")
    rfw = rfp+".mif"
    fw = open(rfw, "w+")
    inst = fo.readline()
    while inst != "" :
        b=bin(int(inst[0:-1],16))[2:]
        zn = 32 - len(b)
        for i in range(zn):
            fw.write("0")
        fw.write(b)
        fw.write("\n")
        inst = fo.readline()


# fo.close()
miftrans('./inst_rom.data')
